package MediaOnline.General;

import MediaOnline.GUI.R;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.widget.ImageView;

public class DownloadImages extends AsyncTask<String, Void, Drawable> {
	
	public ImageView iv;
	public String url;
	public Context ctx;
	Drawable img;
	
	public DownloadImages(Context ctx, String url, ImageView iv){
		this.iv = iv;
		this.url = url;
		this.ctx = ctx;
		
	}
	
	protected void onPostExecute(Drawable result) {
		// TODO Auto-generated method stub
		super.onPostExecute(result);
		if (img!=null) {
			iv.setImageDrawable(img);
		}
		
	}

	@Override
	protected void onPreExecute() {
		// TODO Auto-generated method stub
		super.onPreExecute();
		iv.setImageResource(R.drawable.noimg);
		
	}

	@Override
	protected Drawable doInBackground(String... params) {
		// TODO Auto-generated method stub
		downloadImage d = new downloadImage();
		img = d.downloadDrawable(url);
		
		return img;
		
	}

}
